<%@page import="cz.acies.data.persist.UserPerson"%>
<%@page import="cz.acies.data.process.UserProcessor"%>
<%@page import="cz.acies.data.UserContext"%>
<%@page import="cz.acies.utils.UIDGenerator"%>
<%@page import="org.apache.commons.lang3.time.DateFormatUtils"%>
<%@page import="cz.acies.genea.data.dao.*"%>
<%@page import="cz.acies.genea.data.persist.*"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
String theme = "metro";

Map<String, Object> params = new HashMap<String, Object>();
Enumeration<String> e = request.getParameterNames();
while (e.hasMoreElements()) {
    String key =  e.nextElement();
    params.put(key, request.getParameter(key));
}
UserContext uCtx = (UserContext) session.getAttribute("uCtx");
if (uCtx == null) {

} else if (uCtx.getLogin() != null && uCtx.getLogin().getPerson() != null) {
	//UserPerson up = (UserPerson) uCtx.getLogin().getPerson(); 
	UserProcessor process = new UserProcessor();
	UserPerson person = process.refreshUserPerson((UserPerson) uCtx.getLogin().getPerson());
	uCtx.getLogin().setPerson(person);
}
//System.out.println("uCtx: "+uCtx);
UserPerson record = (UserPerson) uCtx.getLogin().getPerson();
request.setAttribute("record", record);
%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="<%=path%>/libs/themes/<%=theme%>/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/libs/themes/icon.css">
<style type="text/css">
body {
	font-family: sans-serif;
	font-size: 11px;
	margin: 0px;
}
.genea-textfiled input {
	border: 1px solid rgb(212,163,117); 
	font-size: 11px;
}
</style>

<script type="text/javascript" src="<%=path%>/libs/jquery-1.9.1.js"></script>
<script type="text/javascript" src="<%=path%>/libs/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=path%>/libs/aciea.utils.js"></script>
<script type="text/javascript">
$(document.body).ready(function() {});

$.extend($.fn.validatebox.defaults.rules, {
	equals: {
		validator: function(value,param){
			var value $(param[0]).val();
			return value;
		},
		message: "Nesprávný formát."
	}
});
</script>
</head>

<body>
	<form id="userEditForm" method="post">
		<input id="processId" name="processId" type="hidden" value="">
		<input id="modulId" name="modulId" type="hidden" value="LX.M.USER">
		<input id="id" name="id" type="hidden" value="${record.id}">
		<script type="text/javascript">
		$("#userEditForm").form({
			onSubmit: function() {
				$("#processId").val("doUpdate")
				var url = "<%= path%>/pages/user_process.jsp";
				var params = (""+JSON.stringify($("#userEditForm").serialize())).trim();
				params = params.substring(1, params.length-1);
				var result = executeAjaxSync(url, params);
				alert("onSubmitresult: "+result);
			},
			success: function(data) {
				//alert(data)
			}
		});
		</script>
		
		<table style="margin: 20px;">
			<tr>
				<td>Jméno:</td>
				<td>
					<input id="firstName" name="firstName" class="easyui-textfiled"
						value="${record.firstName}" style="width: 200px"></input>
				</td>
			</tr>
			<tr>
				<td>Příjmení:</td>
				<td>
					<input id="lastName" name="lastName" class="easyui-textfiled"
						value="${record.lastName}" style="width:200px"></input>
				</td>
			</tr>
			<tr>
				<td>Email:</td>
				<td>
					<input id="email" name="email" class="easyui-textfiled"
						value="${record.email}" style="width:200px"></input>
				</td>
			</tr>
			<tr>
				<td colspan="9"><hr/></td>
			</tr>
		</table>
		<div style="text-align:center;padding:5px">
			<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">Uložit</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" onclick="backForm()">Zpět</a>
		</div>
		<script type="text/javascript">
		function submitForm() {
			//$("#userEditForm").form("submit");
			$("#userEditForm").submit();
		}
		function backForm() {
			alert("Zpět");
		}		
		</script>
	</form>
</body>
</html>
